package com.ncloud.aaaa.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.ncloud.aaaa.model.Func;

public interface FuncRepository extends CrudRepository<Func, Long> {
	Page<Func> findAll(Pageable pageable);

	@Query("select distinct c from UserRole a,RoleFunc b,Func c where "
			+ " a.id.userId = ?1 and a.id.roleId = b.roleId and b.funcId = c.id and c.state = '1' order by c.code")
	List<Func> getFuncListByUserId(Long userId);

	@Query("select distinct c from UserRole a,RoleFunc b,Func c where "
			+ " a.id.userId = ?1 and a.id.roleId = b.roleId and b.funcId = c.id and c.code=?2 and c.state = '1' order by c.code")
	List<Func> getFuncListByUserIdAndFuncCode(long userId, String funcCode);
}
